﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Watson.TemporaryFilesDeleter.Properties;

namespace Watson.TemporaryFilesDeleter.UI.Windows
{
    /// <summary>
    /// Providers a user interface for editing application preferences.
    /// </summary>
    public partial class OptionsEditor : Form
    {
        #region Private Fields

        /// <summary>
        /// The editable current session settings.
        /// </summary>
        Settings currentSessionSettings = Settings.CurrentSession;

        /// <summary>
        /// The editable current session settings.
        /// </summary>
        Settings defaultSettings = Settings.Default;

        #endregion

        #region Event Handlers

        private void btnApply_Click(object sender, EventArgs e)
        {
            SaveSettings();

            // TODO: Error handling.
        }
        
        private void btnOK_Click(object sender, EventArgs e)
        {
            SaveSettings();

            this.DialogResult = DialogResult.OK;

            // TODO: Error handling.
        }

        #endregion

        #region Private Methods

        /// <summary>
        /// Initialises the settings editor controls.
        /// </summary>
        private void InitialiseSettingsEditors()
        {
            this.currentSessionSettingsEditor.Settings =
                this.currentSessionSettings;

            this.defaultSettingsEditor.Settings =
                this.defaultSettings;
        }

        /// <summary>
        /// Saves the edited settings.
        /// </summary>
        private void SaveSettings()
        {
            this.currentSessionSettingsEditor.Save();

            this.defaultSettingsEditor.Save();
        }

        #endregion

        #region Public Constructors

        /// <summary>
        /// Initialises a new instance of the OptionsEditor class.
        /// </summary>
        public OptionsEditor()
        {
            InitializeComponent();

            //PopulateComboBoxes();
            InitialiseSettingsEditors();
            //SetInitialViewState();
            //SetControlEnabledState();
            //AttachEventHandlers();
        }

        #endregion
    }
}
